package jicheng;

//添加集合并且遍历

import java.util.ArrayList;

public class test {
    public static void main(String[] args) {
        ArrayList<student> array = new ArrayList<>();

        student s1 = new student("张三", 20);
        student s2 = new student("李四", 22);
        student s3 = new student("王五", 25);

        array.add(s1);
        array.add(s2);
        array.add(s3);

        for (int i = 0; i < array.size(); i++) {
            student s = array.get(i);
            System.out.println(s.getName() + "," + s.getAge());
        }
    }
}
